package com.tanhua.server.controller;

import com.tanhua.server.service.IMService;
import com.tanhua.server.service.MessagesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.lang.reflect.InvocationTargetException;
import java.util.Map;

@RestController
@RequestMapping("/messages")
public class MessagesController {

    @Autowired
    private MessagesService messagesService;

    @Autowired
    private IMService imService;

    @GetMapping("/announcements")
    public ResponseEntity<Object> announcements(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer pagesize) throws InvocationTargetException, IllegalAccessException {
        ResponseEntity<Object> e = messagesService.queryAnnouncements(page, pagesize);
        System.out.println("e = " + e);
        return e;
    }

    @GetMapping("/userinfo")
    public ResponseEntity<Object> userInfo(Long huanxinId) throws InvocationTargetException, IllegalAccessException {
        return imService.queryUserInfo(huanxinId);
    }

}
